/*
 * 2006-04-18 Li Ximing, Zhang Yanbo - Create.
 */
package com.hd123.rumba.log;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;

import com.hd123.rumba.exception.BusinessException;
import com.hd123.rumba.runtime.HibernateSession;
import com.hd123.rumba.runtime.IAfterSaveNew;
import com.hd123.rumba.runtime.IBeforeSave;
import com.hd123.rumba.runtime.ObserverRegistry;

/**
 * Action日志 | 管理员 | 实现类
 * 
 * @author lxm
 * @author zhangyanbo
 * 
 */
public class ActionLogMgr extends OperateLogMgr implements IActionLogMgr {

  public ActionLogMgr() {
    super();
    this.registryClass("com.hd123.rumba.log.IActionLog", "com.hd123.rumba.log.ActionLog");
  }
  
  public IActionLog createLog() {
    return new ActionLog();
  }

  public void saveT(IActionLog log) throws BusinessException, HibernateException {
    this.checkParameterNotNull(log, "log");
    Session ses = HibernateSession.sessionFactory.openSession();
    Transaction tx = ses.beginTransaction();
    try {
      ObserverRegistry.notifyObservers(IBeforeSave.class, log);
      ses.saveOrUpdate(log);
      ObserverRegistry.notifyObservers(IAfterSaveNew.class, log);
      tx.commit();
    } catch (Exception e) {
      tx.rollback();
      throw new BusinessException(e.getMessage());
    } finally {
      ses.flush();
      ses.close();
    }
  }

}
